package scjp.preparation.file;

import java.io.IOException;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;

public class PathInfo1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Path testFilePath = Paths.get("C:\\Dev\\Projects\\MyProjects\\yev-playground\\src\\scjp\\preparation\\file\\testfile.txt");
		// retrieve basic information about path
		System.out.println("Printing file information: ");
		System.out.println("\t file name: " + testFilePath.getFileName());
		System.out.println("\t root of the path: " + testFilePath.getRoot());
		System.out.println("\t parent of the target: " + testFilePath.getParent());
		// print path elements
		System.out.println("Printing elements of the path: ");
		for(Path element : testFilePath) {
		System.out.println("\t path element: " + element);
		}
		
		System.out.println("It's URI is: " + testFilePath.toUri());
		Path testPathNormalized = Paths.get(testFilePath.normalize().toString());
		
		System.out.println("It's normalized absolute path is: " +
				testPathNormalized.toAbsolutePath());
				try {
					System.out.println("It's normalized real path is: " +
					testFilePath.toRealPath (LinkOption.NOFOLLOW_LINKS));
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

	}

}
